﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Shove.Web.UI;

public partial class UserControls_Login : UCBase
{
    public UserControls_Login()
    {
        Name = "登录";

        swpas = new ShoveWebPartAttribute[16];

        swpas[0] = new ShoveWebPartAttribute_Int("控件宽度", "1,1004", 960, "控件宽度");
        swpas[1] = new ShoveWebPartAttribute_Int("导航行高", "1,400", 28, "导航行高");
        swpas[2] = new ShoveWebPartAttribute_Int("用户名行高", "1,400", 28, "用户名行高");
        swpas[3] = new ShoveWebPartAttribute_Int("用户名密码框宽度", "1,600", 150, "用户名密码框宽度");
        
        swpas[4] = new ShoveWebPartAttribute_Text("提示字体CSS样式", "", "td14", "提示字体CSS样式");
        swpas[5] = new ShoveWebPartAttribute_Text("用户名CSS样式", "", "black12", "用户名CSS样式");
        swpas[6] = new ShoveWebPartAttribute_Text("用户名输入框CSS样式", "", "in_p2", "用户名输入框CSS样式");
        swpas[7] = new ShoveWebPartAttribute_Text("注册提示语CSS样式", "", "blue12", "注册提示语CSS样式");
        swpas[8] = new ShoveWebPartAttribute_Text("导航字体颜色", "", "title14_bai", "导航字体颜色");

        swpas[9] = new ShoveWebPartAttribute_Color("控件边框颜色", "#cccccc", "控件边框颜色");

        swpas[10] = new ShoveWebPartAttribute_Image("导航背景图片1", "", "images/UserControls/index_1_03.jpg", "导航背景图片1");
        swpas[11] = new ShoveWebPartAttribute_Image("导航背景图片2", "", "images/UserControls/title_bg_hui.jpg", "导航背景图片2");
        swpas[12] = new ShoveWebPartAttribute_Image("提示行背景图片", "", "images/UserControls/category_bg_1.jpg", "提示行背景图片");
        swpas[13] = new ShoveWebPartAttribute_Image("登陆按钮图片", "", "images/UserControls/login.jpg", "登陆按钮图片");

        swpas[14] = new ShoveWebPartAttribute_Int("导航图片1单元格宽度", "1,1000", 106, "导航图片1单元格宽度");
        swpas[15] = new ShoveWebPartAttribute_Text("头部提示字体CSS样式", "", "black14_2", "提示字体CSS样式");
    }

    private void InitlayOut()
    {
        //tabctr.Width = swpAttributes[0];
        //tabctr.BgColor = swpAttributes[9];

        //tdNum.Height = swpAttributes[1];
        //tdNum.Style.Add("background-image", "url('" + swpAttributes[10] + "')");
        ////tdsign.Style.Add("background-image", "url('" + swpAttributes[11] + "')");
        //tdNum.Attributes.Add("class", swpAttributes[8]);
        ////tdNum.Width = swpAttributes[14];
        tdtishi.Style.Add("background-image", "url('" + swpAttributes[12] + "')");
        tdtishi.Attributes.Add("class", swpAttributes[15]);

        ibLogin.ImageUrl = "~/" + swpAttributes[13];

        tdname.Height = swpAttributes[2];
        tdname.Attributes.Add("class", swpAttributes[5]);
        txtUserName.Width = new Unit(swpAttributes[3]);
        txtUserName.CssClass = swpAttributes[6];
        tdreg.Attributes.Add("class", swpAttributes[7]);

        tdpsw.Height = swpAttributes[2];
        tdpsw.Attributes.Add("class", swpAttributes[5]);
        tdforgrt.Attributes.Add("class", swpAttributes[7]);
        txtPwd.Width = new Unit(swpAttributes[3]);
        txtPwd.CssClass = swpAttributes[6];

        tdcode.Height = swpAttributes[2];
        tdcode.Attributes.Add("class", swpAttributes[5]);
        txtCode.CssClass = swpAttributes[6];
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        InitlayOut();
    }

    protected override void OnLoad(EventArgs e)
    {
        isRequestLogin = false;        

        base.OnLoad(e);
    }

    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        string ReturnDescription = "";

        int Result = new Login().LoginSubmit(this.Page, _Site, txtUserName.Text, txtPwd.Text, txtCode.Text, ref ReturnDescription);

        if (Result < 0)
        {
            Shove._Web.JavaScript.Alert(this.Page, ReturnDescription);

            return;
        }

        new Login().GoToRequestLoginPage(Shove._Web.Session.GetSessionAsString(uConst.RequestLoginPage, "Default.aspx"));
    }
}
